package websocket

type Session struct {
	Fd    		uint64
	connWs		*connectionWs
	//userData 	*AgentUserData
	metaData    map[string] interface{}
}

type AgentUserData struct {
	Uid int32
	Account string
	ClubId int32
	RoomServerAddr string   // 房间服Ip
	RoomServerPtr interface{}
}

func newWsSession(fd uint64, con *connectionWs) *Session {
	return &Session{
		Fd : fd,
		connWs : con,
		//userData : nil,
	}
}

func (s *Session) GetWsConn() *connectionWs {
	return s.connWs
}


func (s *Session) SetMetaData(m map[string] interface{}) {
	s.metaData = m
}
func (s *Session) Set(k string, v interface{}) {
	if s.metaData == nil {
		s.metaData = make(map[string] interface{})
	}
	s.metaData[k] = v
}
func (s *Session) Get(key string) interface{} {
	if s.metaData == nil {
		return nil
	}
	return s.metaData[key]
}
func (s *Session) Del(key string) {
	if s.metaData == nil {
		return
	}
	delete(s.metaData, key)
}
func (s *Session) IsMetaEmpty() bool {
	return s.metaData == nil || len(s.metaData) == 0
}

const metaKeyStayApp = "stay_app"
func (s *Session) GetStayApp() string {
	_app := s.Get(metaKeyStayApp)
	if _app == nil {
		return ""
	}
	return _app.(string)
}
func (s *Session) SetStayApp(app string) {
	s.Set(metaKeyStayApp, app)
}
func (s *Session) DelStayApp() {
	s.Del(metaKeyStayApp)
}


//
//func (s *Session) setUserData(uid int32, account string) {
//	s.userData = &AgentUserData{Uid: uid, Account: account}
//}
//
//// 设置account
//func (s *Session) setAccount(account string) {
//	s.userData.Account = account
//}
//
//// 设置uid
//func (s *Session) setUid(uid int32) {
//	s.userData.Uid = uid
//}
//
//
//func (s *Session) GetUserData() *AgentUserData {
//	return s.userData
//}
//
//func (s *Session) IsSignIn() bool {
//	return !(s.userData.Uid == 0)
//}
